<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <include file="wechat/nav" />
    <form class="well form-inline margin-top-20" method="post" action="{:url('wechat/index')}">
        <label>微信账号</label>
        <select name="account" id="js-account" class="form-control">
            <foreach name="accounts" key="account" item="item">
                <if condition="$defaultAccount eq $account">
                    <option value="{$account}" selected>{$account}</option>
                    <else/>
                    <option value="{$account}">{$account}</option>
                </if>

            </foreach>
        </select>
        <input class="btn btn-primary wechat-menu-push" value="推送菜单" type="button">

    </form>


    <table class="table table-hover table-bordered table-list">
        <thead>
        <tr>
            <th width="50">ID</th>
            <th width="80">微信账号</th>
            <th width="80">菜单名称</th>
            <th width="100">菜单类型</th>
            <th width="200">链接地址</th>
            <th width="200">回复文字</th>
            <th width="200">上级菜单</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <foreach name="wechats" item="vo">
            <tr>
                <td>{$vo.id}</td>
                <td>{$vo.account}</td>
                <td>{$vo.name}</td>
                <td>{$vo.type}</td>
                <td>{$vo.url}</td>
                <td>{$vo.key}</td>
                <td>
                    <if $vo.p_name>{$vo.p_name}
                        <else/>
                        顶级
                    </if>
                </td>
                <td>
                    <a href="{:url('Wechat/view',['id'=>$vo['id']])}">编辑</a> |
                    <a class="js-ajax-delete" href="{:url('Wechat/delete',['id'=>$vo['id']])}">删除</a>
                </td>
            </tr>
        </foreach>
        </tbody>
        <tfoot>
        <tr>
            <th width="50">ID</th>
            <th>微信账号</th>
            <th>菜单名称</th>
            <th>菜单类型</th>
            <th>链接地址</th>
            <th>回复文字</th>
            <th>上级菜单</th>
            <th>操作</th>
        </tr>
        </tfoot>
    </table>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script>
    $('.wechat-menu-push').click(function () {
        var account = $('#js-account option:selected').val();
        $.post('{:url("wechat/push")}', {account: account}, function (data) {
            alert(data.msg);
        });
    });
    $('#js-account').change(function () {
        $('form.margin-top-20').submit();
    });
</script>
</body>
</html>
